﻿<UserControl x:Class=" LocultApp.Views.Pages.EditPageDocuments.EditSolutionDocumentView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="300"
             
             xmlns:local="clr-namespace:LocultApp.Local"
             xmlns:behav="clr-namespace:LocultApp.Behaviours"
            xmlns:ctrls="clr-namespace:DropDownButtonLib.Controls;assembly=DropDownButtonLib"
             >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Row="0" Orientation="Vertical">
            <TextBlock Text="{Binding SourceFileName}" Style="{StaticResource Heading1}" ToolTip="{Binding SourceFilePathName}" Margin="3,3,3,18" />
        </StackPanel>

        <StackPanel Orientation="Vertical" Grid.Row="1" Margin="3">
            <Label Content="{x:Static local:Strings.STR_LABEL_Name}"
                   ContentStringFormat="{}{0}:"
                   Target="{Binding ElementName=txtNewSolutionName}"
                   Margin="0,3,3,0"/>
            <TextBox Text="{Binding SourceFileName, UpdateSourceTrigger=PropertyChanged}" Name="txtNewSolutionName" Margin="3,0,3,3"/>
        </StackPanel>

        <StackPanel Orientation="Vertical" Grid.Row="2">
            <Label Content="{x:Static local:Strings.STR_LABEL_Location}"
                   ContentStringFormat="{}{0}:"
                   Target="{Binding ElementName=txtNewSolutionLocation, UpdateSourceTrigger=PropertyChanged}"
                   Margin="0,3,3,0"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <ctrls:DropDownButton Grid.Column="0"
                                  MinHeight="25"
                                  IsEnabled="True"
                                  Content="..."                              
                                  IsOpen="{Binding DropDownBrowser.IsOpen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                  HorizontalAlignment="Left"
                                  Margin="3" 
                                >
                    <ctrls:DropDownButton.DropDownContent>
                        <StackPanel xmlns:views="clr-namespace:FolderBrowser.Views;assembly=FolderBrowser" IsHitTestVisible="True" Focusable="True">
                            <views:DropDownView DataContext="{Binding DropDownBrowser}" />
                        </StackPanel>
                    </ctrls:DropDownButton.DropDownContent>
                </ctrls:DropDownButton>

                <TextBox Grid.Column="1"
                         Text="{Binding SourceFilePath, UpdateSourceTrigger=PropertyChanged}"
                         Name="txtNewSolutionLocation"
                         Margin="3,0,3,3"/>
            </Grid>
        </StackPanel>

        <GroupBox Header="{x:Static local:Strings.STR_HEADER_Project}" Grid.Row="3" Margin="0" Padding="3">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <Button Grid.Column="0"
                            Content="{x:Static local:Strings.STR_CAPTION_ADD}"
                            Command="{Binding AddTargetFileCommand}"
                            IsEnabled="{Binding ElementName=txtNewEditTarget, Path=Text.Length, UpdateSourceTrigger=PropertyChanged}"
                            Margin="3" />

                    <Button Grid.Column="1"
                            Content="{x:Static local:Strings.STR_CAPTION_REMOVE}"
                            Command="{Binding RemoveTargetFileCommand}"
                            CommandParameter="{Binding ElementName=lstTargetFiles, Path=SelectedItem}"
                            IsEnabled="{Binding ElementName=lstTargetFiles, Path=SelectedItems.Count, UpdateSourceTrigger=PropertyChanged}"
                            Margin="3" />
                </Grid>

                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Label Grid.Row="0"
                                   Content="{x:Static local:Strings.STR_LABEL_PATH}"
                                   ContentStringFormat="{}{0}:"
                                   Target="{Binding ElementName=txtNewEditTarget}"
                                   Margin="0,3,0,3"
                                   />
                            <Grid Grid.Row="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>

                                <Button Grid.Column="0"
                                        Command="{Binding BrowseForTargetFileCommand}"
                                        Content="..."
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Left"
                                        Margin="3,0,3,3" />

                                <TextBox Grid.Column="1"
                                        Text="{Binding NewEditTarget}"
                                        Name="txtNewEditTarget"
                                        Margin="3,0,3,3" />

                            </Grid>
                        </Grid>
                        <Grid Grid.Row="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Label Grid.Row="0"
                                   Content="{x:Static local:Strings.STR_LABEL_Comment}"
                                   ContentStringFormat="{}{0}:"
                                   Target="{Binding ElementName=txtNewEditTargetComment}" Margin="0,3,0,3"/>
                            <TextBox Grid.Row="1" Text="{Binding NewEditTargetComment}" Name="txtNewEditTargetComment" Margin="3,0,3,3" />
                        </Grid>
                    </Grid>

                    <Grid Grid.Row="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <Label Grid.Row="0"
                               Content="{x:Static local:Strings.STR_HEADER_TargetFiles}"
                               ContentStringFormat="{}{0}:"
                               Target="{Binding ElementName=lstTargetFiles}" Margin="0,3,0,3" />
                        <ListBox Grid.Row="1"
                                Name="lstTargetFiles"
                                ItemsSource="{Binding SolutionChildren}"
                                behav:SelectedItemChanged.Command="{Binding SelectedItemChangedCommand}"
                                Margin="3,0,3,3"
                            >
                            <ListBox.ToolTip>
                                <TextBlock Text="{Binding SolutionChildren.Count, StringFormat=Count: {0}}" />
                            </ListBox.ToolTip>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path}" ToolTip="{Binding ItemTip}" Margin="3" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Grid>
                </Grid>
            </Grid>
        </GroupBox>

        <Grid Grid.Row="1" Grid.Column="1" Grid.RowSpan="2"  Margin="9,0,3,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0"
                   Content="{x:Static local:Strings.STR_LABEL_Comment}"
                   ContentStringFormat="{}{0}:"
                   Target="{Binding ElementName=txtSolutionComment}"
                   Margin="0,3,0,3"/>
           <TextBox Grid.Row="1"
                    Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}"
                    TextWrapping="Wrap"
                    AcceptsReturn="True"
                    Name="txtSolutionComment"
                    Margin="3,0,3,3"/>
        </Grid>
    </Grid>
</UserControl>
